<?php


namespace app\api\controller;
use think\DB;

class Ban
{
    public function Ban(){
        {
            //进行数据库查询nav
            $data = Db::name('banner')->alias('ba')
                ->join('attachment b', 'ba.thumb=b.id')
                ->field('ba.id,ba.name,ba.jianjie,b.filepath')
                ->where('fenlei_id',3)
                ->select();
            foreach ($data as $key => &$v) {
                $v['filepath'] = 'http://' . $_SERVER['HTTP_HOST'] . $v['filepath'];
            }
            if ($data) {
                return json(['code' => 200, 'msg' => "成功", 'data' => $data]);
            } else {
                return json(['code' => 0, 'msg' => "失败", 'data' => []]);
            }
        }
    }
}